package org.foreningsgatan.genetics.grid;

import java.io.Serializable;

import org.foreningsgatan.genetics.Program;
import org.foreningsgatan.genetics.SimulationEnvironment;
import org.gridgain.grid.GridException;
import org.gridgain.grid.GridJob;

public class ProgramTask<T extends Serializable, S extends Serializable> implements Serializable, GridJob {
	private SimulationEnvironment<T, S> environment;
	private Program<T, S> program;

	public ProgramTask(SimulationEnvironment<T, S> environment, Program<T, S> program) {
		this.environment = environment;
		this.program = program;
	}

	@Override
	public Serializable execute() throws GridException {
		System.out.println("program=" + program);
		System.out.println("environment=" + environment);
		program.run(environment.cloneAndReset());
		return program;
	}

	@Override
	public void cancel() {
		// TODO Auto-generated method stub
		
	}
	
}
